package bancosys.tec.services.test.services;

import java.util.List;

import jmine.tec.executionlog.ExecutionLogController;
import jmine.tec.services.annotations.ServiceFields;
import jmine.tec.services.api.ActionsEnum;
import jmine.tec.services.api.ServiceExecutionException;
import jmine.tec.services.api.ServicesAPIMessages;
import bancosys.tec.services.api.AbstractService;

/**
 * Mock service used on tests.
 * 
 * @author lundberg
 */
@ServiceFields(action = ActionsEnum.INCLUIR, optional = { MockService.CAMPO_OPCIONAL }, required = { MockService.CAMPO_OBRIGATORIO_1,
        MockService.CAMPO_OBRIGATORIO_2 })
public class MockService extends AbstractService<ExecutionLogController> {

    public static final String CAMPO_OPCIONAL = "campoOpcional";

    public static final String CAMPO_OBRIGATORIO_1 = "campoObrigatorio1";

    public static final String CAMPO_OBRIGATORIO_2 = "campoObrigatorio2";

    /**
     * Validates parameters, throws ServiceExecutionException if they are invalid. Nothing more.
     * 
     * @throws ServiceExecutionException ServiceExecutionException
     */
    public void execute() throws ServiceExecutionException {
        List<String> errors = this.validate();
        if (!errors.isEmpty()) {
            StringBuilder builder = new StringBuilder();
            for (String error : errors) {
                builder.append(error);
            }
            throw new ServiceExecutionException(ServicesAPIMessages.INVALID_SERVICE_PARAMETERS.create(builder));
        }
    }

}
